package com.cx.algrithm.sort;

import java.util.Arrays;

/**
 * @author shkstart
 * @date 7/23/2019 - 2:45 PM
 */
public class SelectionSort {
    public static void main(String[] args) {
        int[] arr = {11, 3, 29, 49, 30, 7, 50, 63, 46, 1, 99};
        selection2(arr);
    }

    private static void selection(int[] arr) {
        int i, j, temp;
        for (i = 0; i < arr.length - 1; i++) {
            for (j = i + 1; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    temp = arr[j];
                    arr[j] = arr[i];
                    arr[i] = temp;
                }
            }
        }

        System.out.println(Arrays.toString(arr));
    }

    private static void selection2(int[] arr) {
        int i, j, temp;
        for (i = 0; i < arr.length - 1; i++) {
            for (j = i + 1; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
